interneurons <- readRDS("../../data/interneurons_kb.rds")
DefaultAssay(interneurons) <- "RNA"
interneurons = FindVariableFeatures(interneurons, selection.method = "vst", nfeatures = 10000)
all.genes = rownames(interneurons)
interneurons = ScaleData(interneurons)
interneurons = RunPCA(interneurons, features = VariableFeatures(object = interneurons))
interneurons = RunUMAP(interneurons, reduction = "pca", dims = 1:30)
interneurons= FindNeighbors(interneurons, reduction = "pca", dims = 1:30)
interneurons = FindClusters(interneurons, resolution = .9)
## Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
##
## Number of nodes: 17927
## Number of edges: 601762
##
## Running Louvain algorithm...
## Maximum modularity in 10 random starts: 0.8284
## Number of communities: 19
## Elapsed time: 2 seconds
DimPlot(interneurons, reduction = "umap", label = TRUE, repel = TRUE,pt.size = 1)

plot_colors = read_delim("../../data/palettes/interneuron_timepoint_pal.txt",
delim = "/n",col_names = F) %>% pull(X1)
time_points <- unique(interneurons@meta.data["timepoint"]) %>% pull(timepoint)
col_n <-set_names(plot_colors,levels(time_points))
#,order = rev(levels(time_points))
DimPlot(interneurons,
reduction = "umap",
repel = TRUE,
group.by = "timepoint",
pt.size = 2,
cols = col_n,order = rev(levels(time_points)))+
ggtitle(label = "")+ theme(legend.position = "none")

pre.critical <- levels(time_points)[1:5]
# Add new timepoint column for pre and post critical period
interneurons@meta.data <- interneurons@meta.data %>%
mutate(timepoint2 = ifelse(timepoint %in% pre.critical,
"E14-P5",
"P7-Adult"))
DimPlot(interneurons, reduction = "umap", label = TRUE, repel = TRUE,pt.size = 1, group.by = "timepoint2")

DimPlot(interneurons, reduction = "umap", label = TRUE, repel = TRUE, split.by = "timepoint2",pt.size = 1)

saveRDS(interneurons,"../../data/interneurons_labeled.RDS")
DefaultAssay(interneurons) <- "RNA"
all.markers <- FindAllMarkers(interneurons,logfc.threshold = 0.25)
sig.markers <- all.markers %>%
filter(p_val_adj < 0.05)
write_csv(sig.markers, file = "sig_markers_1.csv")
table(Idents(interneurons)) %>% kbl(col.names = c("Cluster","Cell Count")) %>% kable_minimal()
|
Cluster
|
Cell Count
|
|
0
|
1886
|
|
1
|
1751
|
|
2
|
1509
|
|
3
|
1388
|
|
4
|
1335
|
|
5
|
1330
|
|
6
|
1268
|
|
7
|
1215
|
|
8
|
1190
|
|
9
|
895
|
|
10
|
810
|
|
11
|
688
|
|
12
|
530
|
|
13
|
525
|
|
14
|
505
|
|
15
|
448
|
|
16
|
327
|
|
17
|
255
|
|
18
|
72
|
DimHeatmap(interneurons, dims = 1:15, cells = 500, balanced = TRUE)

DimPlot(interneurons, reduction = "pca", group.by = "timepoint",pt.size = 1)

DimPlot(interneurons, reduction = "pca", group.by = "timepoint",pt.size = 1,dims=c(2,3))

DimPlot(interneurons, reduction = "pca", group.by = "timepoint",pt.size = 1,dims=c(3,4))

DimPlot(interneurons, reduction = "pca", group.by = "timepoint",pt.size = 1,dims=c(4,5))

DimPlot(interneurons, reduction = "pca", group.by = "timepoint",pt.size = 1,dims=c(5,6))

DimPlot(interneurons, reduction = "pca", group.by = "timepoint",pt.size = 1,dims=c(5,7))

DimPlot(interneurons, reduction = "pca", group.by = "timepoint",pt.size = 1,dims=c(7,8))

interneurons[["percent.olf"]] <- PercentageFeatureSet(interneurons, pattern = "^Olfr")
interneurons[["percent.vmn"]] <- PercentageFeatureSet(interneurons, pattern = "^Vmn")
FeaturePlot(interneurons,features = "percent.olf",label = TRUE, repel = TRUE, min.cutoff = "q10", max.cutoff = "q90",pt.size = 1)

FeaturePlot(interneurons,features = "percent.vmn",label = TRUE, repel = TRUE, min.cutoff = "q10", max.cutoff = "q90",pt.size = 1)
